import { ref } from "vue"

export const useCalculator = (countInit: number) => {
  const count = ref(countInit)
  const add = () => {
    count.value++
  }
  const reduce = () => {
    count.value--
  }
  const AddButton = () => (<button onClick={add}>疯狂+1</button>)
  const ReduceButton = () => (<button onClick={reduce}>疯狂-1</button>)
  return {
    count,
    add,
    reduce,
    AddButton,
    ReduceButton
  }
}
